
$(function(){
	var userid;
	$.post("/CuitShopPlatform/servlet/isLoginController",{"action":"isLogin"}, function(data){
		if(data.loginflag=='0'){
			alert("请先登录");
			window.location.href="login.html";
		}
		$(".rightTopBar").empty();
		var node="<a class='userMsg' href='user.html' id="+data.userid+">"+"欢迎-"+data.username+"</a>";
		$(node).appendTo(".rightTopBar");
		userid=parseInt($(".userMsg").attr("id"));
		$.post("/CuitShopPlatform/servlet/OrderController", {"action":"getordermsg","userid":userid},function(data){
			for(var i in data){
				var sta;
				if(data[i].sta==0){
					sta="未付款";
				}
				else if(data[i].sta==1){
					sta="已付款";
				}
				else if(data[i].sta==2){
					sta="已发货";
				}
				else if(data[i].sta==3){
					sta="已收货";
				}
				var node="<tr><td>"+data[i].orderid+"</td><td>"+data[i].price+"</td>"
					+"<td>"+data[i].ordertime+"</td><td>"+sta+"</td></tr>";
					$(node).appendTo("tbody");
			}
		},"json");
	},"json");

	$(".selectThis").click(function(){
		$(".showMsg").text($(this).text());
		if($(this).attr("id")=="userMsg"){
			alert("未开放！");
		}
		else if($(this).attr("id")=="orderMsg"){
			$("tbody").empty();
			$.post("/CuitShopPlatform/servlet/OrderController", {"action":"getordermsg","userid":userid},function(data){
				for(var i in data){
					var sta;
					if(data[i].sta==0){
						sta="未付款";
					}
					else if(data[i].sta==1){
						sta="已付款";
					}
					else if(data[i].sta==2){
						sta="已发货";
					}
					else if(data[i].sta==3){
						sta="已收货";
					}
					var node="<tr><td>"+data[i].orderid+"</td><td>"+data[i].price+"</td>"
						+"<td>"+data[i].ordertime+"</td><td>"+sta+"</td></tr>";
						$(node).appendTo("tbody");
				}
			},"json");
		}
		else if($(this).attr("id")=="coupon"){
			alert("未开放！");
		}
	});
})